package com.xianguo.datacenter.download.Thread;

import java.io.Closeable;
import java.io.IOException;

public class Download {
	protected String UID;//下载线程ID，定位使用
	protected String path;//文件存放路径
	protected String fileName;//文件名称
	protected String url;//文件地址
	protected double unitProgress;//文件当前百分比进度
	protected int maxProgres;//文件长度
	protected int progres;//文件以下载长度
	protected int speed;//每秒下载速度
	protected DownloadState downloadState;//下载状态true:正在下载，false:暂停下载
	
	public enum DownloadState{
		DOWNLOADING,SUSPEND,CONTINUE
	}
	
	public void AddProgres(int progres){
		this.progres = this.progres + progres;
	}
	
	public void close(Closeable colse){
		try {
			colse.close();
		} catch (IOException e) {
			System.out.println("流关闭异常:"+path+"\\\\"+fileName);
		} catch(Exception e){
			System.out.println("流关闭异常:"+path+"\\\\"+fileName);
		}
	}
	
	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}

	public String getFileName() {
		return fileName;
	}

	public void setFileName(String fileName) {
		this.fileName = fileName;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public double getUnitProgress() {
		return unitProgress;
	}

	public void setUnitProgress(double unitProgress) {
		this.unitProgress = unitProgress;
	}

	public int getMaxProgres() {
		return maxProgres;
	}

	public void setMaxProgres(int maxProgres) {
		this.maxProgres = maxProgres;
	}

	public int getProgres() {
		return progres;
	}

	public void setProgres(int progres) {
		this.progres = progres;
	}

	public int getSpeed() {
		return speed;
	}

	public void setSpeed(int speed) {
		this.speed = speed;
	}

	public String getUID() {
		return UID;
	}

	public void setUID(String uID) {
		UID = uID;
	}

	public DownloadState getDownloadState() {
		return downloadState;
	}

	public void setDownloadState(DownloadState downloadState) {
		this.downloadState = downloadState;
	}

}
